package com.ymatou.run;

import com.android.uiautomator.core.UiCollection;
import com.android.uiautomator.core.UiSelector;

@SuppressWarnings("deprecation")
public class UiSelectorUtil {
	
	UiSelector selector = new UiSelector();
	
	public UiSelectorUtil() {
		
	}
	
	public UiSelectorUtil(UiSelector selector) {
		this.selector = selector;
	}
	
	public static UiCollection getParentCollection(String parentClassName) {
		UiCollection parent_c = new UiCollection(new UiSelector().className(parentClassName));
		
		return parent_c;
	}
	
	public static int getChildNumByCollection(UiCollection parentCollection, String childClassName) {
		
		return parentCollection.getChildCount(new UiSelector().className(childClassName));
	}
	
	public static int getChildNumByClassName(String parentClassName, String childClassName) {
		UiCollection parent_c = UiSelectorUtil.getParentCollection(parentClassName);
		
		return parent_c.getChildCount(new UiSelector().className(childClassName));
	}
}
